<!DOCTYPE html>
<html>
 <head> 
  <title>【Laravel5教程】mac+apache+mysql配置多站点(一)--闫海的个人博客-芒果小叨</title> 
  <!-- meta tags start --> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <meta name="Keywords" content="个人博客,闫海个人博客,laravel项目,laravel教程,laravel5教程" /> 
  <meta name="Description" content="laravel5教程第一章，修改apache配置和hosts文件，配置一个虚拟主机。" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 
  <!-- meta tags end -->
  <!-- favorite icon starts -->
  <link rel="shortcut icon" href="/Public/Index/mobile/images/common/favicon.ico" type="image/x-icon" />
  <!-- favorite icon ends -->
  <!-- CSS files start -->
  <link href="/Public/Index/mobile/css/framework.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/colorbox.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/responsive.css" rel="stylesheet" type="text/css" media="screen" />
  <link href="/Public/Index/mobile/css/hidpi.css" rel="stylesheet" type="text/css" media="screen" />
  <link href="/Public/Index/mobile/css/skin.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/custom.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/elements.css" rel="stylesheet" type="text/css" media="all" />
  <link href="/Public/Index/mobile/css/style.css" rel="stylesheet" type="text/css" media="all" />
  
  <!-- CSS files end -->
  <!-- JavaScript files start --> 
  <script type="text/javascript" src="/Public/Index/mobile/grayscale.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/effects.jquery-ui.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.nivo-slider.min.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/custom.js"></script>
  <script type="text/javascript" src="/Public/Index/mobile/js/jquery.colorbox.min.js"></script>
  
  <!-- JavaScript files end -->
 </head>
 <body>
  <!-- website wrapper starts -->
  <div class="websiteWrapper"> 
   <!-- main menu wrapper starts --> 
   <div class="mainMenuOuterWrapper"> 
    <a href="#" class="mainMenuCloseButton"></a> 
    <ul class="mainMenuWrapper"> 
     <li class="currentPage"><a href='/mobile.php/index.html' title='首页'>首页</a></li>
      <li><a href='/mobile.php/list/2.html' title='关于我'>关于我<span> </span></a></li><li><a href='/mobile.php/list/3.html' title='时光轴'>时光轴<span> </span></a></li><li><a href='/mobile.php/list/1.html' title='品味人生'>品味人生<span> </span></a></li><li><a href='/mobile.php/list/5.html' title='技术分享'>技术分享<span> </span></a></li>     <li><a href='/mobile.php/index/article/message.html'  title='给我留言'>给我留言</a></li>
    </ul> 
   </div> 
   <!-- main menu wrapper ends --> 

<script type="text/javascript">
  var url = '/mobile.php/article';
  $(function(){
    var id = '48';
    $.post(url+'/addClick',{'id':id},function(data){
        $("#pclick").html('点击数：' + data);
    });
  })
</script>
   <!-- header wrapper starts --> 
   <div class="headerOuterWrapper pageHeaderWrapper"> 
    <div class="headerWrapper"> 
     <a class="mainLogo" href="/mobile.php/index.html"><img src="/Public/Index/mobile/images/mainLogo.png" alt="" /></a> 
     <a href="#" class="mainMenuButton"></a>
    </div>
    <!-- page title starts --> 
    <h5 class="pageTitle">当前位置：
	<a href="/mobile.php/index.html">首页</a>&nbsp;&gt;&nbsp;
	<a href="/mobile.php/list/5.html">技术分享</a>
	&nbsp;&gt;&nbsp;<a href="/mobile.php/list/17.html">Laravel教程</a>
	</h5>    <!-- page title ends --> 
   </div>
   <!-- header wrapper ends --> 
   <!-- page wrapper starts --> 
   <div class="pageWrapper singlePostPageWrapper"> 
    <!-- post content wrapper starts --> 
    <div class="singlePostContentWrapper">
    <h3 class="pageTitle" style="background:#F0F0F0;color:#333;text-align:center;">【Laravel5教程】mac+apache+mysql配置多站点(一)</h3> 
     <div class="pageSpacer"></div> 
     <div class="pageSpacer"></div> 
     <div style="word-break: break-all;" class="phoneContent"><p>首先修改apache，配置一个虚拟主机。（apache安装目录默认在：/etc/apache2/ ,etc目录是隐藏目录,打开终端：open /etc 可以显示这个目录）<br/>在终端输入：<br/></p><pre class="brush:bash;toolbar:false">sudo&nbsp;vim&nbsp;/etc/apache2/httpd.conf</pre><p>找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉#，开启虚拟主机配置<br/></p><pre class="brush:bash;toolbar:false">:wq
sudo&nbsp;apachectl&nbsp;restart
sudo&nbsp;vi&nbsp;/etc/apache2/extra/httpd-vhosts.conf</pre><p>配置虚拟主机，下面配置仅供参考(以下配置既可以访问localhost，也可以访问lv，mytest.com)<br/></p><pre class="brush:bash;toolbar:false">&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;/Library/WebServer/Documents&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;localhost
&nbsp;&nbsp;&nbsp;&nbsp;ErrorLog&nbsp;&quot;/private/var/log/apache2/localhost-error_log&quot;
&nbsp;&nbsp;&nbsp;&nbsp;CustomLog&nbsp;&quot;/private/var/log/apache2/localhost-access_log&quot;&nbsp;common
&lt;/VirtualHost&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;ServerAdmin&nbsp;webmaster@dummy-host.example.com
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;/usr/yan/lv/public&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;lv
&nbsp;&nbsp;&nbsp;&nbsp;ErrorLog&nbsp;&quot;/private/var/log/apache2/dummy-host.example.com-error_log&quot;
&nbsp;&nbsp;&nbsp;&nbsp;CustomLog&nbsp;&quot;/private/var/log/apache2/dummy-host.example.com-access_log&quot;&nbsp;common
&lt;/VirtualHost&gt;
&lt;VirtualHost&nbsp;*:80&gt;
&nbsp;&nbsp;&nbsp;&nbsp;ServerAdmin&nbsp;webmaster@dummy-host2.example.com
&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;&quot;/usr/yan/mytest/public&quot;
&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;mytest.com
&nbsp;&nbsp;&nbsp;&nbsp;ErrorLog&nbsp;&quot;/private/var/log/apache2/dummy-host2.example.com-error_log&quot;
&nbsp;&nbsp;&nbsp;&nbsp;CustomLog&nbsp;&quot;/private/var/log/apache2/dummy-host2.example.com-access_log&quot;&nbsp;common
&lt;/VirtualHost&gt;</pre><p>apache配置完毕，保存并重启，再改一下hosts文件就可以完成多站点的配置了。<br/>改hosts：<br/></p><pre class="brush:bash;toolbar:false">sudo&nbsp;vi&nbsp;/etc/hosts</pre><p>在文件末尾加上：<br/></p><pre class="brush:bash;toolbar:false">127.0.0.1&nbsp;lv
127.0.0.1&nbsp;mytest.com</pre><p>保存退出<br/></p><pre class="brush:bash;toolbar:false">sudo&nbsp;apachectl&nbsp;restart</pre><p>这样，只需要把Documents文件夹下创建lv和mytest目录，把laravel项目放在对应文件夹下，浏览器访问lv和mytest.com就是两个独立的laravel项目。<br/>从下一章开始，以mytest（mytest.com）为例，构建一个博客项目 。 <br/></p></div>
     <div class="textBreak"></div> 
    </div> 
    <!-- post content wrapper ends --> 
    <!-- post info starts --> 
    <div class="singlePostInfoWrapper">
     <span class="singleIconWrapper singleIconText iconCalendarDark postInfo postDate">2015-07-21</span>
     <a class="singleIconWrapper singleIconText iconEditDark postInfo postAuthor postInfoNoMargin">小叨</a>&nbsp;&nbsp;
     <span class="singleIconWrapper singleIconText iconArrowRightDark" id="pclick">点击数：156</span>
    </div> 
    <!-- post info ends --> 
    <!-- post links wrapper starts --> 
    <div class="singlePostContentWrapper"> 
     <p>上一篇：<a href="/mobile.php/article/47.html">Laravel5.1配置</a></p>
     <p>下一篇：已经是最后一篇文章了</p>
    </div> 
    <!-- post links wrapper ends --> 
    <!-- comments section wrapper starts --> 
    <div class="commentsSectionWrapper"> 
     <h4 class="commentsTitle">相关阅读：</h4> 
     <!-- comments wrapper starts --> 
     <!-- accordion item wrapper starts --> 
        <div class="accordionContent"> 
         <p><a href="/mobile.php/article/48.html" title="【Laravel5教程】mac+apache+mysql配置多站点(一)">【Laravel5教程】mac+apache+mysql配置多站点(一)</a></p><p><a href="/mobile.php/article/47.html" title="Laravel5.1配置">Laravel5.1配置</a></p><p><a href="/mobile.php/article/46.html" title="laravel5.1安装">laravel5.1安装</a></p><p><a href="/mobile.php/article/45.html" title="初探Laravel5">初探Laravel5</a></p>        </div> 
     <!-- accordion item wrapper ends -->
     <!-- coments wrapper ends --> 
    </div> 
    <!-- comments section wrapper ends --> 
   </div> 
   <!-- page wrapper ends --> 
   <!-- footer wrapper starts --> 
   <div class="footerWrapper"> 
    <!-- copyright wrapper starts --> 
    <div class="copyrightWrapper"> 
     <!-- copyright starts --> 
     <span class="copyright"><a href="http://www.miitbeian.gov.cn/">鲁ICP备15004472号-1</a></span> 
     <!-- copyright ends --> 
     <!-- back to top button starts --> 
     <a href="" class="backToTopButton"></a> 
     <!-- back to top button ends --> 
    </div> 
    <!-- copyright wrapper ends --> 
   </div> 
   <!-- footer wrapper ends --> 
  </div>
  <!-- website wrapper ends -->
 </body>
</html>